var profile = null;
$(document).ready(function() {
	console.log("load profile page");
	var table = $('.table').DataTable();

	$('.table tbody').on( 'click', 'tr', function () {
        if ( $(this).hasClass('selected') ) {
            $(this).removeClass('selected');
        }
        else {
            table.$('tr.selected').removeClass('selected');
            $(this).addClass('selected');
            var href = this.getElementsByTagName('a')[0].getAttribute('href');
            var m = href.match(/profile=(\d+)/);
            if( m ){
                profile = m[1]
                $('#ok').removeAttr("disabled");
            }
        }
    } );

    $('#ok').attr("disabled",true);
} );


function on_click_ok()
{
    window.location.href = '/running/profile/set?p='+profile;
}

